<template>
  <!--员工会员-->
  <div>
    <div class="search"><input type="text" placeholder="请输入预约姓名/手机号搜索" v-model="content"><img
      src="../../assets/search.png" alt="" width="16" @click="goSearch()"></div>
    <div class="page-infinite-wrapper" ref="wrapper" :style="{ height: wrapperHeight + 'px' }">
      <wv-group
        v-infinite-scroll="getList"
        infinite-scroll-disabled="loading"
        infinite-scroll-distance="10"
      >
        <ul class="list">
          <li v-for="item in list">
            <ul>
              <li>{{item.phone}}<span>{{item.userName}}</span>
                <span style="font-size: 8px">会员账号：{{item.accountName}}</span>
                <wv-button type="default" :mini="true" class="lookdetail" v-if="item.appointmentState==1"
                           @click="goAppointment(item)">预约操作
                </wv-button>
              </li>
              <li>{{item.targetName}}
                <span class="wait" v-if="item.appointmentState==0">无需预约</span>
                <span v-if="item.appointmentState==1">等待预约</span>
                <span class="no" v-if="item.appointmentState==2">预约成功</span>
                <span class="weiguo" v-if="item.appointmentState==3">预约失败</span>
              </li>
              <li>
                <span v-if="item.soureType==1">预约来源：商城购买</span>
                <span v-if="item.soureType==2">预约来源：会员权益使用 会员卡号{{item.vipCardNo}}</span>
              </li>
              <li>
                <span v-if="item.identityType==1">证件类型：身份证 </span>
                <span v-if="item.identityType==2">证件类型：护照 </span>
                <span v-if="item.identityType==3">证件类型：港澳通行证 </span>
                <span v-if="item.identityType==4">证件类型：台胞证 </span>
                <span> {{item.identityNo}} </span>
              </li>
              <li>
                <p><span>航班号：{{item.flightNumber}}</span></p>
              </li>
              <li>
                <p><span>始发地：{{item.originatingPlace}} — 到达地{{item.destinationPlace}}</span></p>
              </li>
              <li>
                <p><span>航班起飞时间：{{item.flightDate}} {{item.takeOffTime}}</span></p>
              </li>
              <li>
                <span>使用次数：{{item.appointmentUseNum}}</span>
              </li>
              <li>
                <span>提交日期：{{item.createDate}}</span>
              </li>
            </ul>
          </li>
        </ul>
      </wv-group>
    </div>
    <div class="model" v-show="isVisible">
      <div class="bg"></div>
      <div class="modelContent">
        <div>
          <ul class="list">
            <li>{{appointment.phone}}<span>{{appointment.userName}}</span>
            </li>
            <li>{{appointment.targetName}}
              <span class="wait" v-if="appointment.appointmentState==0">无需预约</span>
              <span v-if="appointment.appointmentState==1">等待预约</span>
              <span class="no" v-if="appointment.appointmentState==2">预约成功</span>
              <span class="weiguo" v-if="appointment.appointmentState==3">预约失败</span>
            </li>
            <li>预约来源：
              <span v-if="appointment.soureType==1">商城购买</span>
              <span v-if="appointment.soureType==2">会员权益使用 会员卡号{{appointment.vipCardNo}}</span>
            </li>
            <li>
              <span v-if="appointment.identityType==1">证件类型：身份证 </span>
              <span v-if="appointment.identityType==2">证件类型：护照 </span>
              <span v-if="appointment.identityType==3">证件类型：港澳通行证 </span>
              <span v-if="appointment.identityType==4">证件类型：台胞证 </span>
              <span>{{appointment.identityNo}}</span>
            </li>
            <li>
              <p><span>航班号：{{appointment.flightNumber}}</span></p>
            </li>
            <li>
              <p><span>始发地：{{appointment.originatingPlace}} — 到达地{{appointment.destinationPlace}}</span></p>
            </li>
            <li>
              <p><span>航班起飞时间：{{appointment.flightDate}} {{appointment.takeOffTime}}</span></p>
            </li>
            <li>
              <span>提交日期：{{appointment.createDate}}</span>
            </li>
          </ul>
          <ul class="list" v-for="item in appointment.peerstaffList" style="text-align: left">
            <li><span>同行人员：{{item.userName}}</span></li>
            <li>
              <span v-if="item.identityType==1">证件类型：身份证 </span>
              <span v-if="item.identityType==2">证件类型：护照 </span>
              <span v-if="item.identityType==3">证件类型：港澳通行证 </span>
              <span v-if="item.identityType==4">证件类型：台胞证 </span>
            </li>
            <li><span>证件号码:{{item.identityNo}}</span></li>
          </ul>
        </div>
        <wv-group>
          <wv-cell
            title="预约结果"
            is-link
            :value="appointmentState.appointmentStateDesc"
            @click.native="appointmentStatePickerShow = true"
          />
          <wv-picker
            :visible.sync="appointmentStatePickerShow"
            :columns="appointmentStateColumns"
            value-key="appointmentStateDesc"
            @confirm="confirmAppointmentState"
          />
        </wv-group>
        <wv-group class="textarea">
          <wv-input placeholder="预约校验码" v-model="useCode"></wv-input>
        </wv-group>
        <p class="btn">
          <wv-button type="default" :mini="true" @click="appointmentCheckSub()">提交</wv-button>
          <wv-button type="default" :mini="true" @click="isVisible=false">取消</wv-button>
        </p>
      </div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import {getAppointmentList, employeeAppointmentCheckSub} from '../../../test/unit/http'
  import {Toast} from 'we-vue'

  export default {
    name: 'appointmentList',
    props: {},
    data() {
      return {
        list: [],
        content: '',
        accountGoodsId: '',
        page: 1,
        rows: 3,
        pages: 0,
        useCode: '',
        wrapperHeight: 0,
        loading: false,
        isVisible: false,
        appointment: {},
        appointmentState: [{appointmentState: 0, appointmentStateDesc: '请选择'}],
        appointmentStatePickerShow: false,
        appointmentStateColumns: [
          {
            values: [
              {appointmentState: 2, appointmentStateDesc: '预约成功'},
              {appointmentState: 3, appointmentStateDesc: '预约失败'}
            ],
            defaultIndex: 0
          }
        ]
      };
    },
    methods: {
      getAppointmentData(params) {
        getAppointmentList(params).then(res => {
          console.log(res);
          if (res.code == 100) {
            let data = res.object;
            let list = data.rows;
            let pages = data.pages;
            this.pages = pages;
            let totalNum = data.totalNum;
            this.totalNum = totalNum;
            if (list.length > 0) {
              this.list = this.list.concat(list);
            }
            if (this.page < this.pages) {
              this.page++;
              this.loading = false
            } else {
              this.loading = true
            }
          } else {
            Toast.fail(res.info);
          }
        })
      },
      getList() {
        this.loading = true;
        let params = {
          appointType: 1,
          content: this.content,
          page: this.page,
          rows: this.rows
        };
        this.getAppointmentData(params);
      },
      goSearch() {
        this.getList();
      },
      goAppointment(appointment) {
        this.isVisible = true;
        this.appointment = appointment
      },
      confirmAppointmentState(picker) {
        console.log(picker);
        this.appointmentState[0] = picker.getValues()[0];
      },
      appointmentCheckSub() {
        let appointmentState = this.appointmentState[0].appointmentState;
        if (appointmentState == 0) {
          Toast.text('请选择预约结果');
          return;
        }
        let params = this.appointment;
        params.appointmentState = appointmentState;
        params.useCode = this.useCode;
        params.remindWay = 3;
        employeeAppointmentCheckSub(params).then(res => {
          if (res.code == 100) {
            Toast.text('提交成功');
          } else {
            Toast.fail(res.info);
          }
          this.isVisible = false;
          this.getList();
        });
      }
    },
    created() {
    },
    components: {}
  }
</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  .search {
    position: relative;
    width: 95%;
    margin: 10px auto;

    input {
      width: 90%;
      border: 1px solid #eee;
      box-shadow: 0 3px 4px rgba(17, 17, 17, 0.05);
      border-radius: 7px;
      height: 43px;
      line-height: 43px;
      padding: 10px;
      color: #111;
    }

    img {
      position: absolute;
      right: 20px;
      top: 27px;
    }
  }

  .list {
    > li {
      margin: 15px 10px;
      text-align: left;
      border-bottom: 1px solid #ddd;

      li {
        margin-bottom: 10px;
      }

      li:first-child {
        font-size: 16px;
        color: #111;
        font-weight: 700;

        span {
          color: #999;
          margin-left: 10px;
        }

        button {
          float: right;
        }

        .shenheing {
          float: right;
          color: #2d93f0;
          font-size: 13px;
          font-weight: normal;
        }

        .lookdetail {
          background-color: #fff;
          border: 1px solid #f98e3c;
          color: #f98e3c;
        }
      }

      li:nth-child(2) {
        line-height: 35px;
        height: 35px;
        color: #111;
        font-size: 17px;
        font-weight: 700;

        span {
          font-size: 15px;
          float: right;
          color: #f98e3c;
        }

        .wait {
          color: #717171;
        }

        .weiguo {
          color: #2d93f0;
        }

        .no {
          color: #e96673;
        }
      }

      li:nth-child(3) {
        font-size: 12px;
        color: #666;
        display: flex;
        text-align: left;

        p {
          flex: 1;
        }

        p:last-child {
          text-align: right;
        }

        .lookdetail {
          background-color: #fff;
          border: 1px solid #f98e3c;
          color: #f98e3c;
          height: 30px;
        }
      }

      li:nth-child(4) {
        font-size: 12px;
        color: #666;
        display: flex;
        text-align: left;

        img {
          margin-right: 5px;
        }

        p {
          flex: 1;
        }
      }

      li:nth-child(5) {
        text-align: left;
      }

      li:nth-child(5) {
        font-size: 12px;
        color: #666;
        display: flex;
        text-align: left;

        img {
          margin-right: 5px;
        }

        p {
          flex: 1;
        }
      }

      li:nth-child(6) {
        text-align: left;
      }

      li:nth-child(6) {
        font-size: 12px;
        color: #666;
        display: flex;
        text-align: left;

        img {
          margin-right: 5px;
        }

        p {
          flex: 1;
        }
      }

      li:nth-child(7) {
        text-align: left;
      }

      li:nth-child(7) {
        font-size: 12px;
        color: #666;
        display: flex;
        text-align: left;

        img {
          margin-right: 5px;
        }

        p {
          flex: 1;
        }
      }

      li:nth-child(8) {
        text-align: left;
      }

      li:nth-child(8) {
        font-size: 12px;
        color: #666;
        display: flex;
        text-align: left;

        img {
          margin-right: 5px;
        }

        p {
          flex: 1;
        }
      }

      li:last-child {

        img {
          vertical-align: middle;
        }

        span {
          color: #666;
          font-size: 12px;
          text-align: right;
        }
      }
    }

    > li:last-child {
      border-bottom: none;
    }
  }

  .bg {
    background-color: rgba(0, 0, 0, 0.3);
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 50px;
  }

  .model .modelContent {
    background-color: #fff;
    /*border-radius: 8px;*/
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 2;
    width: 100%;
    padding: 15px 0;

    .textarea .weui-cell {
      border: 1px solid #ddd;
      border-radius: 5px;
      background-color: #f8f8f8;
      width: 81%;
      margin: auto;
    }

    li:first-child {
      margin-bottom: 10px;
    }

    .btn {
      text-align: right;
      padding: 15px 15px 0;

      button {
        height: 30px;
        line-height: 30px;
        color: #fff;
        width: 75px;
        border-radius: 25px;
      }

      button:last-child {
        background-color: #ccc;
        border: 1px solid #ccc;
        color: #fff;
      }

      button:first-child {
        background-color: #f98e3c;
        margin-right: 20px;

      }
    }
  }
</style>

